package com.xiaoq.matrix.weixin;

import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;

import com.xiaoq.coms.util.WeixinXmlUtil;

@XmlRootElement(name = "xml")
@XmlAccessorType(XmlAccessType.FIELD)
public class WXMessage {

	@XmlElement(name = "ToUserName")
	@XmlJavaTypeAdapter(XmlCDATAAdapter.class)
	private String toUserName;

	@XmlElement(name = "FromUserName")
	@XmlJavaTypeAdapter(XmlCDATAAdapter.class)
	private String fromUserName;

	@XmlElement(name = "CreateTime")
	private Long createTime;

	@XmlElement(name = "MsgType")
	@XmlJavaTypeAdapter(XmlCDATAAdapter.class)
	private String msgType;

	@XmlElement(name = "Content")
	@XmlJavaTypeAdapter(XmlCDATAAdapter.class)
	private String content;

	@XmlElement(name = "MsgId")
	private String msgId;
	
	

	public String getToUserName() {
		return toUserName;
	}



	public void setToUserName(String toUserName) {
		this.toUserName = toUserName;
	}



	public String getFromUserName() {
		return fromUserName;
	}



	public void setFromUserName(String fromUserName) {
		this.fromUserName = fromUserName;
	}



	public Long getCreateTime() {
		return createTime;
	}



	public void setCreateTime(Long createTime) {
		this.createTime = createTime;
	}



	public String getMsgType() {
		return msgType;
	}



	public void setMsgType(String msgType) {
		this.msgType = msgType;
	}



	public String getContent() {
		return content;
	}



	public void setContent(String content) {
		this.content = content;
	}



	public String getMsgId() {
		return msgId;
	}



	public void setMsgId(String msgId) {
		this.msgId = msgId;
	}



	public static void main(String[] argv) {
		String xml = "<xml>\r\n" + 
				"<ToUserName><![CDATA[toUser]]></ToUserName>\r\n" + 
				"<FromUserName><![CDATA[fromUser]]></FromUserName>\r\n" + 
				"<CreateTime>12345678</CreateTime>\r\n" + 
				"<MsgType><![CDATA[text]]></MsgType>\r\n" + 
				"<Content><![CDATA[你好]]></Content>\r\n" + 
				"</xml>";
		WXArticleMessage msg = WeixinXmlUtil.fromString(WXArticleMessage.class, xml);
		System.out.println(msg.getMsgType());
		System.out.println(WeixinXmlUtil.asXml(msg));
	}

}
